#!/bin/bash
# 计算 5 秒内 qps 变化
INTERVAL=5

result1=$(mysql -uroot -pTest@1234 -h127.0.0.1 -Ne "show global status like 'Queries';" | awk '{ print $2 }' )

sleep ${INTERVAL}s

result2=$(mysql -uroot -pTest@1234 -h127.0.0.1 -Ne "show global status like 'Queries';" | awk '{ print $2 }' )

now=$(date '+%Y-%m-%d %H:%M:%S')

qps_diff=$((result2 - result1))
qps_rate=$(echo "scale=4; $qps_diff / $INTERVAL" | bc)

echo $now
echo "QPS: $qps_rate"

